//
// Created by User on 24-10-3.
//
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <libavutil/frame.h>

#include "general_decoder.h"
#include "general_demuxer.h"
TEST(decoder_test, decoder_init)
{
    demuxer::general_demuxer demuxer(VIDEO_PATH);
    auto& video_stream = *demuxer.get_streams().front();
    decoder::general_decoder decoder(video_stream);
}

TEST(decoder_test, decoder_get_frame)
{
    demuxer::general_demuxer demuxer(VIDEO_PATH);
    auto& video_stream = *demuxer.get_streams().front();
    decoder::general_decoder decoder(video_stream);
    int i = 1;
    for (;; i++)
    {
        auto frame = decoder.get_frame();
        if (!frame)
        {
            break;
        }
        LOG(INFO) << "frame : " << i << "\t pts : " << frame.get_frame()->pts
            << "\t dts : " << frame.get_frame()->pkt_dts;
    }
}

TEST(decoder_test, decoder_get_frame2)
{
    demuxer::general_demuxer demuxer(VIDEO_PATH);
    auto& audio_stream = *demuxer.get_streams()[1];
    decoder::general_decoder decoder(audio_stream);
    int i = 1;
    for (;; i++)
    {
        auto frame = decoder.get_frame();
        if (!frame)
        {
            break;
        }
        LOG(INFO) << "frame : " << i << "\t pts : " << frame.get_frame()->pts
            << "\t dts : " << frame.get_frame()->pkt_dts;
    }
}
